package com.xzx.helloworld;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

/**
 * 比较TimeDecoder，TimeDecoderV2是使用ReplayingDecoder的，ReplayingDecoder会自动处理数据碎片化问题
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/10/15 11:14
 */
public class TimeDecoderV2 extends ReplayingDecoder<Void> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        out.add(in.readBytes(4));
    }
}
